<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = & get_instance();
	if(!isUserLogin()){
		redirect(site_url());exit();
	}
	$live_match_array = $ci->match_entity->getMyLiveMatch(getUserId());
?>
<div id="center_content">
	<div class="clrboth"></div>
	<div class="block">
		<div class="title" style="position:relative;">
			<h3 style="font-weight:bold;"><a href="<?php echo site_url("cricket/user/dashboard")?>">Dashboard</a> &raquo; My Live Tournaments</h3>
			<a class="back_button2" href="<?php echo site_url("cricket/user/dashboard")?>" title="Back?">Back?</a>		
		</div>
		<div class="clrboth"></div>
		<?php foreach($live_match_array as $tournament => $match_array) :?>
			<?php $TOURNAMENT = $ci->tournament_entity->init('id', $tournament);?>
			<div class="title">
				<span class="collapse uncollapse" rel="div_tournament_<?php echo $tournament;?>">&nbsp;</span>
				<h3 class="bold">
					Tournament: <?php echo strtoupper($TOURNAMENT->getName());?> 
				</h3>
			</div>
			<div class="clrboth"></div>
			<div class="content" id="div_tournament_<?php echo $tournament;?>">
				<?php foreach($match_array as $match=> $id) : ?>
					<?php 
						$MATCH = $ci->match_entity->init('id',$id);
						$TEAM_HOME = clone_($ci->team_entity->init('id',$MATCH->getHome()));
						$TEAM_AWAY = clone_($ci->team_entity->init('id',$MATCH->getAway()));
					?>
					<div class="rowitem2">
						<div class="grid1">&nbsp;</div>
						<div class="grid6" style="text-align:center;"><h4><?php echo $MATCH->getTitle();?></h4></div>
						<div class="clrboth"></div>
						
						<div class="grid3">
							<div class="team">
								<?php echo thumb($TEAM_HOME->getMyFlagTeam(),IMG_TEAMPIC_W,IMG_TEAMPIC_H);?>
								<div class="clrboth"></div>
								<span class="bold">
									<?php echo $MATCH->displayMatchInfo('home');?>
								</span>
								<div class="clrboth"></div>
							</div>
						</div>
						
						<div class="grid1" style="text-align:center;width:80px;"><?php echo vs_image(); ?></div>
						
						<div class="grid3">
							<div class="team">
								<?php echo thumb($TEAM_AWAY->getMyFlagTeam(),IMG_TEAMPIC_W,IMG_TEAMPIC_H);?>
								<div class="clrboth"></div>
								<span class="bold">
									<?php echo $MATCH->displayMatchInfo('away');?>
								</span>
								<div class="clrboth"></div>
							</div>
						</div>
					 
						<div class="grid4" style="position:relative;">
							<span class="predict" onclick="go_predict(<?php echo $TOURNAMENT->getId();?>,<?php echo $MATCH->getId();?>,'<?php echo mCrypt($TOURNAMENT->getId().$MATCH->getId());?>');"></span>
							<div class="clrboth"></div>
							<div class="clock-wrap">
								<div class="wrap">
									<div class="title-clock">Match Ends In: </div>
									<div class="clrboth"></div>
									<span class="yellow countdown upper" id="countdown_m_<?php echo $MATCH->getId();?>" rel="<?php echo ($MATCH->getEndTime() - time() );?>"></span> 
								</div>
							</div>
						</div>
						<div class="clrboth"></div>
						
						<div class="grid7">
							<div class="result-text" style="text-align:center;"><?php echo $MATCH->displayMatchInfo('closed');?></div>
						</div>
					</div>
					
					<div class="clrboth"></div>
				 <?php endforeach;?>
				<div class="clrboth"></div>
			</div>	
		<?php endforeach;?>
	</div>	
	<div class="clrboth"></div>
</div>	